package com.timesheet.gui.efforttracker.composite;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class SectionLeaveComposite extends Composite {
	
	private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
	
	public SectionLeaveComposite(Composite parent, int style) {
		super(parent, style);
		addDisposeListener(new DisposeListener() {

			public void widgetDisposed(DisposeEvent e) {
				toolkit.dispose();
			}
		});
		toolkit.adapt(this);
		toolkit.paintBordersFor(this);
		setLayout(new GridLayout(1, false));
		
		Section sctnSearchLeaves = toolkit.createSection(this, Section.TWISTIE | Section.TITLE_BAR);
		sctnSearchLeaves.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		toolkit.paintBordersFor(sctnSearchLeaves);
		sctnSearchLeaves.setText("Search");
		sctnSearchLeaves.setExpanded(true);
		
		
		LeaveSearchComposite leaveSearchComposite = new LeaveSearchComposite(sctnSearchLeaves, SWT.NONE);
		toolkit.adapt(leaveSearchComposite);
		toolkit.paintBordersFor(leaveSearchComposite);
		sctnSearchLeaves.setClient(leaveSearchComposite);
		
		Section sctnNewEffort = toolkit.createSection(this, Section.TWISTIE | Section.TITLE_BAR);
		sctnNewEffort.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		toolkit.paintBordersFor(sctnNewEffort);
		sctnNewEffort.setText("Search for Leaves");
		sctnNewEffort.setExpanded(true);
		
		LeaveResultComposite createNewEffortComposite = new LeaveResultComposite(sctnNewEffort, SWT.NONE);
		toolkit.adapt(createNewEffortComposite);
		toolkit.paintBordersFor(createNewEffortComposite);
		sctnNewEffort.setClient(createNewEffortComposite);
	}

}
